package com.sky.context;

public class BaseContext {

    public static ThreadLocal<Long> threadLocal = new ThreadLocal<>();

    public static void setCurrentId(Long id) {
        threadLocal.set(id);
    }

    //BaseContext.getCurrentId() 之所以能获取到当前用户的 userId，
    // 本质上是因为系统在请求到达业务代码之前（通常通过拦截器、过滤器或AOP）已经解析了前端携带的 Token（如JWT)
    public static Long getCurrentId() {
        return threadLocal.get();
    }

    public static void removeCurrentId() {
        threadLocal.remove();
    }

}
